package com.yu.task.controller;

import com.yu.task.globalResult.R;
import com.yu.task.pojo.BlogTag;
import com.yu.task.service.BlogTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/blogTag")
public class BlogTagController {
    @Autowired
    private BlogTagService blogTagService;

    @PostMapping("/insertBlogTag")
    public R insertBlogTag(@RequestBody BlogTag[] blogTag){
        int i = blogTagService.insertBlogTag(blogTag);
        if (i >= 1) {
            return R.success("添加成功"+i+"条");
        }
        return R.failure("添加失败");
    }

    @PostMapping("/deleteByTagId")
    public R deleteByTagId(@RequestParam Long blogId,Long tagId){
        int i = blogTagService.deleteByTagId(blogId,tagId);
        if (i == 1) {
            return R.success("删除成功");

        }
        return R.failure("删除失败");
    }



}
